package supuwoerc.service.impl;

import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.annotation.Transactional;
import supuwoerc.dao.AccountDao;
import supuwoerc.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service("accountService")
public class AccountServiceImpl implements AccountService {
    @Autowired
    @Qualifier("userDao")
    private AccountDao accountDao;
    //转账方法 使用注解方式进行事务控制
    @Transactional
    public void transfer(String outMan, String inMan, double num) {
        accountDao.sub(outMan,num);
        int i =  1/0;   //手动制造异常
        accountDao.add(inMan,num);
    }
}
